﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCRUM.Core.DAO;

namespace SCRUM.Core.BusinessObjects
{
    /// <summary>
    /// Holds information about event tight to specific person
    /// </summary>
    public class Availability
    {

        /// <summary>
        /// ID of an event
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// Duration of event ends this day
        /// </summary>
        public DateTime FromDateTime
        {
            get;
            set;
        }

        /// <summary>
        /// Duration of event ends at this day
        /// </summary>
        public DateTime ToDateTime
        {
            get; set;
        }

        /// <summary>
        /// Short name for event
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Description of reason for event
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Involved user
        /// </summary>
        private User user;

        /// <summary>
        /// Lazy loading for user returns User object
        /// </summary>
        public User User { 
            get {
                if (this.user == null)
                {
                    this.user = DAOUser.GetUserByID(userID);
                }
                return this.user;
        } 
            set 
            {
                this.user = value;
            }
        }
        /// <summary>
        /// ID of involved user
        /// </summary>
        private int userID;

        /// <summary>
        /// Default constructor
        /// </summary>
        public Availability()
        { 
        }

        /// <summary>
        /// Constructor with all required atributes
        /// </summary>
        /// <param name="ID">ID</param>
        /// <param name="from">From date</param>
        /// <param name="to">To date</param>
        /// <param name="name">Name</param>
        /// <param name="desc">Description</param>
        /// <param name="userID">Id of user that is involved</param>
        public Availability(int ID, DateTime from, DateTime to, string name, string desc, int userID)
        {
            this.ID = ID;
            this.FromDateTime = from;
            this.ToDateTime = to;
            this.Name = name;
            this.Description = desc;
            this.userID = userID;
        }
    }
}
